local desc_1v1 = [[
# 无限火力1v1

1.该模式下双方都有十滴血。

2.每局游戏都会给两名玩家提供两个Buff(固定跋扈+一个随机buff)。

3.每当全场造成伤害量达到4点时，两名玩家各获得一个新技能(从四名武将的技能中挑选)，并摸两张牌（最多触发四次）

___

# 随机buff表

**柳暗花明**    每回合限两次，你于回合外失去牌时，摸一张牌

**面面俱到**    准备阶段，从牌堆里获得基本，锦囊牌各一张

**多多益善**    每回合结束，摸一张牌

**蓄势待发**    每回合杀造成的第一次伤害+1。
]]



local m_1v1_getLogic = function()
    local m_1v1_logic = GameLogic:subclass("cf_firemode_logic")


    function m_1v1_logic:chooseGenerals()
        local room = self.room
        local generalNum = room:getSettings('generalNum')
        local n = room:getSettings('enableDeputy') and 1 or 1
        local lord = room:getLord()
        local lord_generals = {}

        if lord ~= nil then
            room.current = lord
            room:setBanner("@[:]cf_firemode_rule", "cf_firemode-intro")
            room:setBanner("@cf_firemode_assignment", "cf_firemode-assign")
            room:setBanner("cf_firemode_as", 4)
            room:setBanner("@cf_firemode_assignmentprocess", "0 / 4")
        end
        local nonlord = room.players
        local generals = room:getNGenerals(#nonlord * generalNum)
        table.shuffle(generals)
        local req = Request:new(nonlord, "AskForGeneral")
        for i, p in ipairs(nonlord) do
            local arg = table.slice(generals, (i - 1) * generalNum + 1, i * generalNum + 1)
            req:setData(p, { arg, n })
            req:setDefaultReply(p, table.random(arg, n))
        end



        local selected = {}
        for _, p in ipairs(nonlord) do
            local result = req:getResult(p)
            local general, deputy = result[1], result[2]
            table.insertTableIfNeed(selected, result)
            room:findGeneral(general)
            room:findGeneral(deputy)
            room:prepareGeneral(p, general, deputy)
        end

        generals = table.filter(generals, function(g) return not table.contains(selected, g) end)
        room:returnToGeneralPile(generals)
        room:askToChooseKingdom(nonlord)
    end

    function m_1v1_logic:broadcastGeneral() --血量置为10血
        local room = self.room
        local players = room.players

        for _, p in ipairs(players) do
            assert(p.general ~= "")
            local general = Fk.generals[p.general]
            p.maxHp = 10
            p.hp = 10
            p.shield = 0
            room:broadcastProperty(p, "general")
            room:broadcastProperty(p, "kingdom")
            room:broadcastProperty(p, "deputyGeneral")
            room:broadcastProperty(p, "maxHp")
            room:broadcastProperty(p, "hp")
            room:broadcastProperty(p, "shield")
        end
    end

    function m_1v1_logic:attachSkillToPlayers()
        local room = self.room
        if room:getSettings('enableDeputy') then
            return true
        end
        local players = room.players
        local addRoleModSkills = function(player, skillName)
            local skill = Fk.skills[skillName]
            if not skill then
                fk.qCritical("Skill: " .. skillName .. " doesn't exist!")
                return
            end
            if skill:hasTag(Skill.Lord) and not (player.role == "lord" and player.role_shown and room:isGameMode("role_mode")) then
                return
            end

            if skill:hasTag(Skill.AttachedKingdom) and not table.contains(skill:getSkeleton().attached_kingdom, player.kingdom) then
                return
            end

            room:handleAddLoseSkills(player, skillName, nil, false, true)
            self:trigger(fk.EventAcquireSkill, player, skill)
        end
        for _, p in ipairs(room.alive_players) do
            local skills = Fk.generals[p.general].skills
            for _, s in ipairs(skills) do
                addRoleModSkills(p, s.name)
            end
            for _, sname in ipairs(Fk.generals[p.general].other_skills) do
                addRoleModSkills(p, sname)
            end

            local deputy = Fk.generals[p.deputyGeneral]
            if deputy then
                skills = deputy.skills
                for _, s in ipairs(skills) do
                    addRoleModSkills(p, s.name)
                end
                for _, sname in ipairs(deputy.other_skills) do
                    addRoleModSkills(p, sname)
                end
            end
        end
    end

    return m_1v1_logic
end




local m_1v1_mode = fk.CreateGameMode {
    name = "cf_firemode",
    minPlayer = 2,
    maxPlayer = 2,
    rule = "#cf_firemode_rule",
    logic = m_1v1_getLogic,
    surrender_func = function(self, playedTime)
        return { { text = "时长大于一分钟一分钟可投降", passed = playedTime >= 60 } }
    end,

}
Fk:loadTranslationTable {
    ["cf_firemode"] = "无限火力1v1",
    [":cf_firemode"] = desc_1v1,
    ["cf_firemode-intro"] = "无限火力(点击查看)",
    [":cf_firemode-intro"] = [[该模式下双方都有十滴血，每局游戏都会给两名玩家提供两个Buff(固定跋扈+一个随机buff)。每当全场造成伤害量达到4点时，两名玩家各获得一个新技能,并摸两张牌（最多累计触发四次）。

  随机buff表:

  柳暗花明：每回合限2次，你于回合外失去牌时，摸一张牌。

  面面俱到:准备阶段，从牌堆里获得基本，锦囊牌各一张。

  多多益善:每回合结束，摸一张牌。

  蓄势待发:每回合杀造成的第一次伤害+1。]],
    ["cf_firemode-assign"] = "累计造成4点伤害",
    ["@cf_firemode_buff"] = "",
    ["@cf_firemode_assignment"] = "目标",
    ["@[:]cf_firemode_rule"] = "模式",
    ["@cf_firemode_assignmentprocess"] = "伤害进度",
    ["cf_firemode_reward"] = "选择一个武将技能并获得",
}

return m_1v1_mode
